package com.art.sunflower.mapper;

import com.art.sunflower.pojo.Classroom;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface ClassroomMapper {

    @Select("select * from classroom_and_teacher_view")
    List<Map<String, Object>> selectList();

    @Insert("insert into classroom(teacher_id, room_name, grade, message, cla_num) values(#{id}, #{name}, #{grade}, #{message}, #{num})")
    void insertClassroom(Integer id, String name, String grade, String message, Integer num);

    @Select("select * from classroom where id = #{id}")
    Map<String, Object> selectClassroom(Integer id);

    @Update("update classroom set teacher_id = #{teacherId}, room_name = #{name}, grade = #{grade}, message = #{message}, cla_num = #{num} where id = #{id}")
    void updateStudent(Integer id, Integer teacherId, String name, String grade, String message, Integer num);

    @Delete("delete from classroom where id = #{id}")
    void delete(Integer id);

    @Select("select * from classroom_and_teacher_view where id = #{id}")
    Map<String, Object> selectById(Integer id);

    @Insert("insert into classroom(room_name,message,grade, teacher_id,cla_num) values(#{roomName},#{message}," +
            "#{grade},#{teacherId},#{claNum})")
    int insert(Classroom classroom);

    @Select("select * from classroom")
    List<Classroom> selectAll();

    @Select("select id from Classroom where id=#{id}")
    int selectOneClassroom(int id);

    @Select("select * from classroom_teacherName where username=#{teacherName}")
    List<Map<String, Object>> findClassroomByTeacher(String teacherName, int pagenum, int pagesize);
}
